//声明列表
function add(...rest: number[]): number;
function add(...rest: string[]): string;

//函数重载
function add(...rest: any[]): any {
    let first = rest[0];
    if (typeof first === "string") {
        return rest.join("");
    }
    if (typeof first === "number") {
        return rest.reduce((pre, cur) => pre + cur);
    }
}

add(1, 2, 3);			// 6
add("a", "b", "c");	// abc